package io.terminus.injector;

import com.baomidou.mybatisplus.core.injector.AbstractMethod;
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
import com.baomidou.mybatisplus.extension.injector.methods.AlwaysUpdateSomeColumnById;
import com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn;
import com.baomidou.mybatisplus.extension.injector.methods.LogicDeleteByIdWithFill;
import io.terminus.injector.method.DeleteAll;

import java.util.List;

/**
 * @author li.chunlong lcl253-137@alibaba-inc.com
 * @desc 自定义SQL注入器
 * @date 2021-09-28
 */
public class CustomSqlInjector extends DefaultSqlInjector {

    @Override
    public List<AbstractMethod> getMethodList(Class<?> mapperClass) {
        List<AbstractMethod> methodList = super.getMethodList(mapperClass);
        methodList.add(new DeleteAll());

        /*// 批量新增数据,自选字段insert
        methodList.add(new InsertBatchSomeColumn(tableFieldInfo -> !tableFieldInfo.isLogicDelete()));
        // 根据id逻辑删除数据,并带字段填充功能
        methodList.add(new LogicDeleteByIdWithFill());
        // 根据ID更新固定的那几个字段(但是不包含逻辑删除)
        methodList.add(new AlwaysUpdateSomeColumnById(tableFieldInfo -> !"name".equals(tableFieldInfo.getColumn())));*/

        return methodList;
    }
}
